//! \file CParameter.cpp
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

// Project Includes
#include "CParameter.h"

// Standard Includes
#include <iostream>


namespace code_sheriff
{


// =====[ Public Methods ]======================================================


// =============================================================================
// CParameter::CParameter
// -----------------------------------------------------------------------------
CParameter::CParameter()
{
  // Reset ourselves to the cleared condition.
  clear();
}


// =============================================================================
// CParameter::~CParameter
// -----------------------------------------------------------------------------
CParameter::~CParameter()
{
  // TODO Auto-generated destructor stub
}


// =============================================================================
// CParameter::setKey
// -----------------------------------------------------------------------------
void CParameter::setKey(TKEY Key)
{
  // Set our key as requested.
  m_Key = Key;
}


// =============================================================================
// CParameter::setValue
// -----------------------------------------------------------------------------
void CParameter::setValue(std::string Value)
{
  // Clear the values in our list.
  m_Values.clear();

  // Append the value to our value list.
  appendValue(Value);
}


// =============================================================================
// CParameter::appendValue
// -----------------------------------------------------------------------------
void CParameter::appendValue(std::string Value)
{
  // Append the value to our value list.
  m_Values.push_back(Value);
}


// =============================================================================
// CParameter::getKey
// -----------------------------------------------------------------------------
TKEY CParameter::getKey(void)
{
  return (m_Key);
}


// =============================================================================
// CParameter::getValue
// -----------------------------------------------------------------------------
TERROR CParameter::getValue(std::string& Value, int Index)
{
  std::vector<std::string>::iterator Iterator;    // TODO: document

  // Validate our arguments.
  if (Index >= m_Values.size())
    { return (ERROR_INVALID_ARGUMENT); } // Index exceeds our list.

  // Copy the requested index value for return.
  Value = m_Values[Index];

  // Finally, return success.
  return (ERROR_NONE);

}


// =============================================================================
// CParameter::clear
// -----------------------------------------------------------------------------
void CParameter::clear(void)
{
  // Clear all member variables.
  m_Key = KEY_INVALID;  // Invalid key.
  m_Values.clear();     // No values in our list.
}


// =============================================================================
// CParameter::print
// -----------------------------------------------------------------------------
void CParameter::print(void)
{
  std::vector<std::string>::iterator Iterator;

  // Print out the key to the standard output.
//  std::cout << "Key [" << m_Key << "] "; TODO: use or loose.
//  std::cout << "Key [" << CKey::get(m_Key)->Long << "] ";
  std::cout << "Key [" << CKey::get(m_Key)->Brief << "] ";

  // Iterate through each value and output the value to standard output.
  for (Iterator = m_Values.begin(); Iterator != m_Values.end(); Iterator++)
  {
    std::cout << "Value [" << *Iterator << "] ";
  }

  // Add a new line.
  std::cout << std::endl;
}


} // namespace code_sheriff
